package com.jy.adscm.operation.hscrb.controller;


import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.hscrb.bean.BzPackagingdetail;
import com.jy.adscm.operation.hscrb.service.BzPackagingdetailService;
import com.jy.adscm.support.SimpleCoreResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyl
 * @since 2018-12-17
 */
@RestController
@RequestMapping("/adscm/operation/bzPackagingdetail")
public class BzPackagingdetailController {
    @Autowired
    BzPackagingdetailService bzPackagingdetailService;
    @RequestMapping("insert")
    public SimpleCoreResponse insert(@RequestBody BzPackagingdetail bzPackagingdetail, HttpServletRequest request) throws AdscmSystemException {
        bzPackagingdetail.setBeginaddtime(new Date());
        boolean insert = bzPackagingdetailService.insert(bzPackagingdetail);
        return new SimpleCoreResponse("200","新增成功",insert);
    }

    @RequestMapping("delete/{id}")
    public SimpleCoreResponse delete(@PathVariable Integer id)throws AdscmSystemException {
        boolean result = bzPackagingdetailService.deleteById(id);
        return new  SimpleCoreResponse("200","删除成功",result);
    }
    @RequestMapping("update")
    public SimpleCoreResponse update(@RequestBody BzPackagingdetail bzPackagingdetail, HttpServletRequest request) throws AdscmSystemException{
        Boolean result = bzPackagingdetailService.updateBzPackagingdetail(bzPackagingdetail);
        return  new SimpleCoreResponse("200","修改成功",result);
    }
    @RequestMapping("selectByTid/{tid}")
    public  SimpleCoreResponse  selectByTid(@PathVariable String tid) throws  AdscmSystemException{
        List<BzPackagingdetail> BzPackagingdetails = bzPackagingdetailService.selectByTid(tid);
        return  new SimpleCoreResponse("200","查询成功",BzPackagingdetails);
    }

    @RequestMapping("selectUser")
    public  SimpleCoreResponse  selectUser() throws  AdscmSystemException{
        List<JyUser> jyUsers = bzPackagingdetailService.selectUser();
        return  new SimpleCoreResponse("200","查询成功",jyUsers);
    }
}

